package top.zlcode.common.core.enums;

import lombok.Getter;

import java.util.Objects;

@Getter
public enum ProgramType {

    JAVA(0, "Java"),
    CPP(1, "C++"),
    C(2, "C");

    private final Integer value;

    private final String desc;

    ProgramType(Integer value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public static ProgramType getByValue(Integer value) {
        if (value == null) {
            return ProgramType.JAVA;
        }
        // 遍历所有枚举值，匹配value
        for (ProgramType type : values()) {
            if (Objects.equals(type.value, value)) {
                return type;
            }
        }
        return ProgramType.JAVA;
    }
}
